package com.hx.springboot1.dao;

import com.hx.springboot1.pojo.dto.AccountListDTO;
import com.hx.springboot1.pojo.entity.TabUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface UserDao {
    @Select("select * from tab_user where username = #{username}")
    TabUser login(String username);

    @Select("select * from tab_user where user_id = #{id}")
    TabUser selectById(int id);

    @Select("select * from tab_user where username like #{name}")
    List<TabUser> selectAllUserByName(String name);
    @Select("select * from tab_user")
    List<TabUser> selectAllUser();
    @Update("update tab_user SET user_state = #{state} where user_id = #{id}")
    void updateUserState(int state,int id);
    @Update("update tab_user SET password = #{name} where user_id = #{id}")
    void resetPwd(String name,int id);
    @Insert("insert into tab_user(username,password,registerTime,user_state) values(#{name},#{name},now(),'0')")
    void insertUser(String name);
    @Update("update tab_user set password = #{newPWD} where user_id = #{userId}")
    int updatePWD(int userId,String newPWD);
}
